package yaml

import (
	"ginx/config"
	"github.com/jinzhu/copier"
)

// Config 静态资源
type Config struct {
	// Main nginx中的main并不是一个块，我们这里分散定义
	Events Events `yaml:"events"`
	Http   Http   `yaml:"http"`
}

type Events struct {

}

type Http struct {
	ServerList []Server `yaml:"server_list"`
}

type Server struct {
	Listen int 				`yaml:"listen"`
	ServerName string 		`yaml:"server_name"`
	LocationList []Location `yaml:"location_list"`
}

type Location struct {
	LocationName string `yaml:"location"`
}

// Config ==> config.Config
// c ==> config
func (c Config) config() config.Config {
	var config config.Config
	//fmt.Println("c:", c)
	//fmt.Println("config:", config)
	// copier.Copy(to, from)
	copier.Copy(&config, &c)
	//fmt.Println("config:", config)
	return config
}